﻿namespace Vibstudio.NetConfigurator.UI.Util
{
    using System.Globalization;
    using System.Management;

    public static class OSInfo
    {
        private static readonly ManagementObjectSearcher searcher = new ManagementObjectSearcher("root\\CIMV2", "SELECT * FROM Win32_OperatingSystem");

        public static string BootDevice
        {
            get
            {
                try
                {
                    foreach (ManagementObject queryObj in searcher.Get())
                    {
                        return queryObj["BootDevice"].ToString();
                    }
                    return "";
                }
                catch
                {
                    return "";
                }
            }
        }

        public static string BuildNumber
        {
            get
            {
                try
                {
                    foreach (ManagementObject queryObj in searcher.Get())
                    {
                        return queryObj["BuildNumber"].ToString();
                    }
                    return "";
                }
                catch
                {
                    return "";
                }
            }
        }

        public static string BuildType
        {
            get
            {
                try
                {
                    foreach (ManagementObject queryObj in searcher.Get())
                    {
                        return queryObj["BuildType"].ToString();
                    }
                    return "";
                }
                catch
                {
                    return "";
                }
            }
        }

        public static string Caption
        {
            get
            {
                try
                {
                    foreach (ManagementObject queryObj in searcher.Get())
                    {
                        return queryObj["Caption"].ToString();
                    }
                    return "";
                }
                catch
                {
                    return "";
                }
            }
        }

        public static string CodeSet
        {
            get
            {
                try
                {
                    foreach (ManagementObject queryObj in searcher.Get())
                    {
                        return GetCodeSetName(queryObj["CodeSet"].ToString());
                    }
                    return "";
                }
                catch
                {
                    return "";
                }
            }
        }

        public static string CountryCode
        {
            get
            {
                try
                {
                    foreach (ManagementObject queryObj in searcher.Get())
                    {
                        return GetCountryCodeName(queryObj["CountryCode"].ToString());
                    }
                    return "";
                }
                catch
                {
                    return "";
                }
            }
        }

        public static string CSDVersion
        {
            get
            {
                try
                {
                    foreach (ManagementObject queryObj in searcher.Get())
                    {
                        return "" + queryObj["CSDVersion"];
                    }
                    return "";
                }
                catch
                {
                    return "";
                }
            }
        }

        public static string CSName
        {
            get
            {
                try
                {
                    foreach (ManagementObject queryObj in searcher.Get())
                    {
                        return queryObj["CSName"].ToString();
                    }
                    return "";
                }
                catch
                {
                    return "";
                }
            }
        }

        public static string CurrentTimeZone
        {
            get
            {
                try
                {
                    foreach (ManagementObject queryObj in searcher.Get())
                    {
                        return ConvertToTimeZone(queryObj["CurrentTimeZone"].ToString());
                    }
                    return "";
                }
                catch
                {
                    return "";
                }
            }
        }

        public static string Description
        {
            get
            {
                try
                {
                    foreach (ManagementObject queryObj in searcher.Get())
                    {
                        return queryObj["Description"].ToString();
                    }
                    return "";
                }
                catch
                {
                    return "";
                }
            }
        }

        public static bool Distributed
        {
            get
            {
                try
                {
                    foreach (ManagementObject queryObj in searcher.Get())
                    {
                        if (queryObj["Distributed"].ToString() == "True") return true;
                        return false;
                    }
                    return false;
                }
                catch
                {
                    return false;
                }
            }
        }

        public static long FreePhysicalMemory
        {
            get
            {
                try
                {
                    foreach (ManagementObject queryObj in searcher.Get())
                    {
                        return long.Parse(queryObj["FreePhysicalMemory"].ToString());
                    }
                    return 0;
                }
                catch
                {
                    return 0;
                }
            }
        }

        public static long FreeSpaceInPagingFiles
        {
            get
            {
                try
                {
                    foreach (ManagementObject queryObj in searcher.Get())
                    {
                        return long.Parse(queryObj["FreeSpaceInPagingFiles"].ToString());
                    }
                    return 0;
                }
                catch
                {
                    return 0;
                }
            }
        }

        public static long FreeVirtualMemory
        {
            get
            {
                try
                {
                    foreach (ManagementObject queryObj in searcher.Get())
                    {
                        return long.Parse(queryObj["FreeVirtualMemory"].ToString());
                    }
                    return 0;
                }
                catch
                {
                    return 0;
                }
            }
        }

        public static string InstallDate
        {
            get
            {
                try
                {
                    foreach (ManagementObject queryObj in searcher.Get())
                    {
                        return ConvertToDateTime(queryObj["InstallDate"].ToString());
                    }
                    return "";
                }
                catch
                {
                    return "";
                }
            }
        }

        public static string LastBootUpTime
        {
            get
            {
                try
                {
                    foreach (ManagementObject queryObj in searcher.Get())
                    {
                        return ConvertToDateTime(queryObj["LastBootUpTime"].ToString());
                    }
                    return "";
                }
                catch
                {
                    return "";
                }
            }
        }

        public static string LocalDateTime
        {
            get
            {
                try
                {
                    foreach (ManagementObject queryObj in searcher.Get())
                    {
                        return ConvertToDateTime(queryObj["LocalDateTime"].ToString());
                    }
                    return "";
                }
                catch
                {
                    return "";
                }
            }
        }

        public static string Locale
        {
            get
            {
                try
                {
                    foreach (ManagementObject queryObj in searcher.Get())
                    {
                        return GetLocaleName(queryObj["Locale"].ToString());
                    }
                    return "";
                }
                catch
                {
                    return "";
                }
            }
        }

        public static string Manufacturer
        {
            get
            {
                try
                {
                    foreach (ManagementObject queryObj in searcher.Get())
                    {
                        return queryObj["Manufacturer"].ToString();
                    }
                    return "";
                }
                catch
                {
                    return "";
                }
            }
        }

        public static long MaxNumberOfProcesses
        {
            get
            {
                try
                {
                    foreach (ManagementObject queryObj in searcher.Get())
                    {
                        return long.Parse(queryObj["MaxNumberOfProcesses"].ToString());
                    }
                    return 0;
                }
                catch
                {
                    return 0;
                }
            }
        }

        public static long MaxProcessMemorySize
        {
            get
            {
                try
                {
                    foreach (ManagementObject queryObj in searcher.Get())
                    {
                        return long.Parse(queryObj["MaxProcessMemorySize"].ToString());
                    }
                    return 0;
                }
                catch
                {
                    return 0;
                }
            }
        }

        public static string Name
        {
            get
            {
                try
                {
                    foreach (ManagementObject queryObj in searcher.Get())
                    {
                        return queryObj["Name"].ToString();
                    }
                    return "";
                }
                catch
                {
                    return "";
                }
            }
        }

        public static long NumberOfProcesses
        {
            get
            {
                try
                {
                    foreach (ManagementObject queryObj in searcher.Get())
                    {
                        return long.Parse(queryObj["NumberOfProcesses"].ToString());
                    }
                    return 0;
                }
                catch
                {
                    return 0;
                }
            }
        }

        public static long NumberOfUsers
        {
            get
            {
                try
                {
                    foreach (ManagementObject queryObj in searcher.Get())
                    {
                        return long.Parse(queryObj["NumberOfUsers"].ToString());
                    }
                    return 0;
                }
                catch
                {
                    return 0;
                }
            }
        }

        public static string OperatingSystemSKU
        {
            get
            {
                try
                {
                    foreach (ManagementObject queryObj in searcher.Get())
                    {
                        return GetOperatingSystemSKUName(int.Parse(queryObj["OperatingSystemSKU"].ToString()));
                    }
                    return "";
                }
                catch
                {
                    return "";
                }
            }
        }

        public static string Organization
        {
            get
            {
                try
                {
                    foreach (ManagementObject queryObj in searcher.Get())
                    {
                        return queryObj["Organization"].ToString();
                    }
                    return "";
                }
                catch
                {
                    return "";
                }
            }
        }

        public static string OSArchitecture
        {
            get
            {
                try
                {
                    foreach (ManagementObject queryObj in searcher.Get())
                    {
                        return queryObj["OSArchitecture"].ToString();
                    }
                    return "";
                }
                catch
                {
                    return "";
                }
            }
        }

        public static string OSLanguage
        {
            get
            {
                try
                {
                    foreach (ManagementObject queryObj in searcher.Get())
                    {
                        return GetOSLanguageName(int.Parse(queryObj["OSLanguage"].ToString()));
                    }
                    return "";
                }
                catch
                {
                    return "";
                }
            }
        }

        public static string OSType
        {
            get
            {
                try
                {
                    foreach (ManagementObject queryObj in searcher.Get())
                    {
                        return GetOSTypeName(int.Parse(queryObj["OSType"].ToString()));
                    }
                    return "";
                }
                catch
                {
                    return "";
                }
            }
        }

        public static bool Primary
        {
            get
            {
                try
                {
                    foreach (ManagementObject queryObj in searcher.Get())
                    {
                        if (queryObj["Primary"].ToString() == "True") return true;
                        return false;
                    }
                    return false;
                }
                catch
                {
                    return false;
                }
            }
        }

        public static string ProductType
        {
            get
            {
                try
                {
                    foreach (ManagementObject queryObj in searcher.Get())
                    {
                        return GetProductTypeName(int.Parse(queryObj["ProductType"].ToString()));
                    }
                    return "";
                }
                catch
                {
                    return "";
                }
            }
        }

        public static string RegisteredUser
        {
            get
            {
                try
                {
                    foreach (ManagementObject queryObj in searcher.Get())
                    {
                        return queryObj["RegisteredUser"].ToString();
                    }
                    return "";
                }
                catch
                {
                    return "";
                }
            }
        }

        public static string SerialNumber
        {
            get
            {
                try
                {
                    foreach (ManagementObject queryObj in searcher.Get())
                    {
                        return queryObj["SerialNumber"].ToString();
                    }
                    return "";
                }
                catch
                {
                    return "";
                }
            }
        }

        public static long ServicePackMajorVersion
        {
            get
            {
                try
                {
                    foreach (ManagementObject queryObj in searcher.Get())
                    {
                        return long.Parse(queryObj["ServicePackMajorVersion"].ToString());
                    }
                    return 0;
                }
                catch
                {
                    return 0;
                }
            }
        }

        public static long ServicePackMinorVersion
        {
            get
            {
                try
                {
                    foreach (ManagementObject queryObj in searcher.Get())
                    {
                        return long.Parse(queryObj["ServicePackMinorVersion"].ToString());
                    }
                    return 0;
                }
                catch
                {
                    return 0;
                }
            }
        }

        public static long SizeStoredInPagingFiles
        {
            get
            {
                try
                {
                    foreach (ManagementObject queryObj in searcher.Get())
                    {
                        return long.Parse(queryObj["SizeStoredInPagingFiles"].ToString());
                    }
                    return 0;
                }
                catch
                {
                    return 0;
                }
            }
        }

        public static string Status
        {
            get
            {
                try
                {
                    foreach (ManagementObject queryObj in searcher.Get())
                    {
                        return queryObj["Status"].ToString();
                    }
                    return "";
                }
                catch
                {
                    return "";
                }
            }
        }

        public static string SystemDevice
        {
            get
            {
                try
                {
                    foreach (ManagementObject queryObj in searcher.Get())
                    {
                        return queryObj["SystemDevice"].ToString();
                    }
                    return "";
                }
                catch
                {
                    return "";
                }
            }
        }

        public static string SystemDirectory
        {
            get
            {
                try
                {
                    foreach (ManagementObject queryObj in searcher.Get())
                    {
                        return queryObj["SystemDirectory"].ToString();
                    }
                    return "";
                }
                catch
                {
                    return "";
                }
            }
        }

        public static string SystemDrive
        {
            get
            {
                try
                {
                    foreach (ManagementObject queryObj in searcher.Get())
                    {
                        return queryObj["SystemDrive"].ToString();
                    }
                    return "";
                }
                catch
                {
                    return "";
                }
            }
        }

        public static long TotalVirtualMemorySize
        {
            get
            {
                try
                {
                    foreach (ManagementObject queryObj in searcher.Get())
                    {
                        return long.Parse(queryObj["TotalVirtualMemorySize"].ToString());
                    }
                    return 0;
                }
                catch
                {
                    return 0;
                }
            }
        }

        public static long TotalVisibleMemorySize
        {
            get
            {
                try
                {
                    foreach (ManagementObject queryObj in searcher.Get())
                    {
                        return long.Parse(queryObj["TotalVisibleMemorySize"].ToString());
                    }
                    return 0;
                }
                catch
                {
                    return 0;
                }
            }
        }

        public static string Version
        {
            get
            {
                try
                {
                    foreach (ManagementObject queryObj in searcher.Get())
                    {
                        return queryObj["Version"].ToString();
                    }
                    return "";
                }
                catch
                {
                    return "";
                }
            }
        }

        public static string WindowsDirectory
        {
            get
            {
                try
                {
                    foreach (ManagementObject queryObj in searcher.Get())
                    {
                        return queryObj["WindowsDirectory"].ToString();
                    }
                    return "";
                }
                catch
                {
                    return "";
                }
            }
        }

        private static string GetCodeSetName(string codeSet)
        {
            long lngCodeSet = long.Parse(codeSet);
            switch (lngCodeSet)
            {
                case 874: return "Thai";
                case 932: return "Japanese";
                case 936: return "Chinese (Simplified) (PRC, Singapore)";
                case 949: return "Korean";
                case 950: return "Chinese (Traditional) (Taiwan, Hong Kong)";
                case 1200: return "Unicode (BMP of ISO 10646, UTF-16LE)";
                case 1201: return "Unicode (BMP of ISO 10646, UTF-16BE)";
                case 1250: return "Latin (Central European Languages)";
                case 1251: return "Cyrillic";
                case 1252: return "Latin (Western European Languages, replacing Code Page 850)";
                case 1253: return "Greek";
                case 1254: return "Turkish";
                case 1255: return "Hebrew";
                case 1256: return "Arabic";
                case 1257: return "Latin (Baltic Languages)";
                case 1258: return "Vietnamese";
                case 65000: return "Unicode (BMP of ISO 10646, UTF-7)";
                case 65001: return "Unicode (BMP of ISO 10646, UTF-8)";
                default: return "Unknown";
            }
        }

        private static string GetCountryCodeName(string countryCode)
        {
            long lngCountryCode = long.Parse(countryCode);
            switch (lngCountryCode)
            {
                case 1: return "United States";
                case 2: return "Canadian-French";
                case 31: return "Netherlands";
                case 32: return "Belgium";
                case 33: return "France";
                case 34: return "Spain";
                case 36: return "Hungary";
                case 39: return "Italy";
                case 41: return "Switzerland";
                case 42: return "Czech Republic/Slovakia";
                case 44: return "United Kingdom";
                case 45: return "Denmark";
                case 46: return "Sweden";
                case 47: return "Norway";
                case 48: return "Poland";
                case 49: return "Germany";
                case 55: return "Brazil";
                case 61: return "International English";
                case 351: return "Portugal";
                case 358: return "Finland";
                default: return "Unknown";
            }
        }

        private static string GetLocaleName(string locale)
        {
            switch (locale)
            {
                case "0436": return "Afrikaans";
                case "041c": return "Albanian";
                case "0401": return "Arabic (Saudi Arabia)";
                case "0801": return "Arabic (Iraq)";
                case "0c01": return "Arabic (Eqypt)";
                case "1001": return "Arabic (Libya)";
                case "1401": return "Arabic (Algeria)";
                case "1801": return "Arabic (Morocco)";
                case "1c01": return "Arabic (Tunisia)";
                case "2001": return "Arabic (Oman)";
                case "2401": return "Arabic (Yemen)";
                case "2801": return "Arabic (Syria)";
                case "2c01": return "Arabic (Jordon)";
                case "3001": return "Arabic (Lebanon)";
                case "3401": return "Arabic (Kuwait)";
                case "3801": return "Arabic (UAE)";
                case "3c01": return "Arabic (Bahrain)";
                case "4001": return "Arabic (Qatar)";
                case "042b": return "Armenian";
                case "042c": return "Azeri (Latin)";
                case "082c": return "Azeri (Cyrillic)";
                case "042d": return "Basque";
                case "0423": return "Belarusian";
                case "0445": return "Bengali (India)";
                case "141A": return "Bosnian (Latin)";
                case "0402": return "Bulgarian";
                case "0403": return "Catalan";
                case "0404": return "Chinese (Taiwan)";
                case "0804": return "Chinese (PRC)";
                case "0c04": return "Chinese (Hong Kong)";
                case "1004": return "Chinese (Singapore)";
                case "1404": return "Chinese (Macau)";
                case "041a": return "Croatian";
                case "101A": return "Croatian (Bosnia Herzegovina)";
                case "0405": return "Czech";
                case "0406": return "Danish";
                case "0465": return "Divehi";
                case "0413": return "Dutch (Standard)";
                case "0813": return "Dutch (Belgian)";
                case "0409": return "English (United States)";
                case "0809": return "English (United Kingdom)";
                case "0c09": return "English (Australian)";
                case "1009": return "English (Canadian)";
                case "1409": return "English (New Zealand)";
                case "1809": return "English (Ireland)";
                case "1c09": return "English (South Africa)";
                case "2009": return "English (Jamaica)";
                case "2409": return "English (Caribbean)";
                case "2809": return "English (Belize)";
                case "2c09": return "English (Trinidad)";
                case "3009": return "English (Zimbabwe)";
                case "3409": return "English (Philippines)";
                case "0425": return "Estonian";
                case "0438": return "Faeroese";
                case "0429": return "Farsi";
                case "040b": return "Finnish";
                case "040c": return "French (Standard)";
                case "080c": return "French (Belgian)";
                case "0c0c": return "French (Canadian)";
                case "100c": return "French (Swiss)";
                case "140c": return "French (Luxembourg)";
                case "180c": return "French (Monaco)";
                case "0437": return "Georgian";
                case "0456": return "Galician";
                case "0407": return "German (Standard)";
                case "0807": return "German (Swiss)";
                case "0c07": return "German (Austrian)";
                case "1007": return "German (Luxembourg)";
                case "1407": return "German (Liechtenstein)";
                case "0408": return "Greek";
                case "0447": return "Gujarati";
                case "040d": return "Hebrew";
                case "0439": return "Hindi";
                case "040e": return "Hungarian";
                case "040f": return "Icelandic";
                case "0421": return "Indonesian";
                case "0410": return "Italian (Standard)";
                case "0810": return "Italian (Swiss)";
                case "0411": return "Japanese";
                case "044b": return "Kannada";
                case "043f": return "Kazakh";
                case "0457": return "Konkani";
                case "0412": return "Korean";
                case "0440": return "Kyrgyz";
                case "0426": return "Latvian";
                case "0427": return "Lithuanian";
                case "042f": return "Macedonian";
                case "043e": return "Malay (Malaysia)";
                case "083e": return "Malay (Brunei Darussalam)";
                case "044c": return "Malayalam";
                case "043a": return "Maltese";
                case "0481": return "Maori";
                case "044e": return "Marathi";
                case "0450": return "Mongolian";
                case "0414": return "Norwegian (Bokmal)";
                case "0814": return "Norwegian (Nynorsk)";
                case "0415": return "Polish";
                case "0416": return "Portuguese (Brazilian)";
                case "0816": return "Portuguese (Standard)";
                case "0446": return "Punjabi";
                case "046b": return "Quechua (Bolivia)";
                case "086b": return "Quechua (Ecuador)";
                case "0c6b": return "Quechua (Peru)";
                case "0418": return "Romanian";
                case "0419": return "Russian";
                case "243b": return "Sami (Inari)";
                case "103b": return "Sami (Lule Norway)";
                case "143b": return "Sami (Lule Sweden)";
                case "0c3b": return "Sami (Northern Finland)";
                case "043b": return "Sami (Northern Norway)";
                case "083b": return "Sami (Northern Sweden)";
                case "203b": return "Sami (Skolt)";
                case "183b": return "Sami (Southern Norway)";
                case "1c3b": return "Sami (Southern Sweden)";
                case "044f": return "Sanskrit";
                case "081a": return "Serbian (Latin)";
                case "181a": return "Serbian (Latin Bosnia Herzegovina)";
                case "0c1a": return "Serbian (Cyrillic)";
                case "1c1a": return "Serbian (Cyrillic Bosnia Herzegovina)";
                case "041b": return "Slovak";
                case "0424": return "Slovenian";
                case "040a": return "Spanish (Traditional Sort)";
                case "080a": return "Spanish (Mexican)";
                case "0c0a": return "Spanish (Modern Sort)";
                case "100a": return "Spanish (Gautemala)";
                case "140a": return "Spanish (Costa Rica)";
                case "180a": return "Spanish (Panama)";
                case "1c0a": return "Spanish (Dominican Republic)";
                case "200a": return "Spanish (Venezuela)";
                case "240a": return "Spanish (Colombia)";
                case "280a": return "Spanish (Peru)";
                case "2c0a": return "Spanish (Argentina)";
                case "300a": return "Spanish (Ecuador)";
                case "340a": return "Spanish (Chile)";
                case "380a": return "Spanish (Uruguay)";
                case "3c0a": return "Spanish (Paraguay)";
                case "400a": return "Spanish (Bolivia)";
                case "440a": return "Spanish (El Salvador)";
                case "480a": return "Spanish (Honduras)";
                case "4c0a": return "Spanish (Nicaragua)";
                case "500a": return "Spanish (Puerto Rico)";
                case "0441": return "Swahili";
                case "041d": return "Swedish";
                case "081d": return "Swedish (Finland)";
                case "045a": return "Syriac";
                case "0449": return "Tamil";
                case "0444": return "Tatar";
                case "044a": return "Telugu";
                case "041e": return "Thai";
                case "0432": return "Tswana";
                case "0422": return "Ukrainian";
                case "041f": return "Turkish";
                case "0420": return "Urdu";
                case "0443": return "Uzbek (Latin)";
                case "0843": return "Uzbek (Cyrillic)";
                case "042a": return "Vietnamese";
                case "0452": return "Welsh";
                case "0434": return "Xhosa";
                case "0435": return "Zulu";
                default: return "Unknown";
            }
        }

        private static string GetOSLanguageName(int language)
        {
            switch (language)
            {
                case 1078: return "Afrikaans";
                case 1052: return "Albanian";
                case 1025: return "Arabic (Saudi Arabia)";
                case 2049: return "Arabic (Iraq)";
                case 3073: return "Arabic (Eqypt)";
                case 4097: return "Arabic (Libya)";
                case 5121: return "Arabic (Algeria)";
                case 6145: return "Arabic (Morocco)";
                case 7169: return "Arabic (Tunisia)";
                case 8193: return "Arabic (Oman)";
                case 9217: return "Arabic (Yemen)";
                case 10241: return "Arabic (Syria)";
                case 11265: return "Arabic (Jordon)";
                case 12289: return "Arabic (Lebanon)";
                case 13313: return "Arabic (Kuwait)";
                case 14337: return "Arabic (UAE)";
                case 15361: return "Arabic (Bahrain)";
                case 16385: return "Arabic (Qatar)";
                case 1067: return "Armenian";
                case 1068: return "Azeri (Latin)";
                case 2092: return "Azeri (Cyrillic)";
                case 1069: return "Basque";
                case 1059: return "Belarusian";
                case 1093: return "Bengali (India)";
                case 5146: return "Bosnian (Latin)";
                case 1026: return "Bulgarian";
                case 1027: return "Catalan";
                case 1028: return "Chinese (Taiwan)";
                case 2052: return "Chinese (PRC)";
                case 3076: return "Chinese (Hong Kong)";
                case 4100: return "Chinese (Singapore)";
                case 5124: return "Chinese (Macau)";
                case 1050: return "Croatian";
                case 4122: return "Croatian (Bosnia Herzegovina)";
                case 1029: return "Czech";
                case 1030: return "Danish";
                case 1125: return "Divehi";
                case 1043: return "Dutch (Standard)";
                case 2067: return "Dutch (Belgian)";
                case 1033: return "English (United States)";
                case 2057: return "English (United Kingdom)";
                case 3081: return "English (Australian)";
                case 4105: return "English (Canadian)";
                case 5129: return "English (New Zealand)";
                case 6153: return "English (Ireland)";
                case 7177: return "English (South Africa)";
                case 8201: return "English (Jamaica)";
                case 9225: return "English (Caribbean)";
                case 10249: return "English (Belize)";
                case 11273: return "English (Trinidad)";
                case 12297: return "English (Zimbabwe)";
                case 13321: return "English (Philippines)";
                case 1061: return "Estonian";
                case 1080: return "Faeroese";
                case 1065: return "Farsi";
                case 1035: return "Finnish";
                case 1036: return "French (Standard)";
                case 2060: return "French (Belgian)";
                case 3084: return "French (Canadian)";
                case 4108: return "French (Swiss)";
                case 5132: return "French (Luxembourg)";
                case 6156: return "French (Monaco)";
                case 1079: return "Georgian";
                case 1110: return "Galician";
                case 1031: return "German (Standard)";
                case 2055: return "German (Swiss)";
                case 3079: return "German (Austrian)";
                case 4103: return "German (Luxembourg)";
                case 5127: return "German (Liechtenstein)";
                case 1032: return "Greek";
                case 1095: return "Gujarati";
                case 1037: return "Hebrew";
                case 1081: return "Hindi";
                case 1038: return "Hungarian";
                case 1039: return "Icelandic";
                case 1057: return "Indonesian";
                case 1040: return "Italian (Standard)";
                case 2064: return "Italian (Swiss)";
                case 1041: return "Japanese";
                case 1099: return "Kannada";
                case 1087: return "Kazakh";
                case 1111: return "Konkani";
                case 1042: return "Korean";
                case 1088: return "Kyrgyz";
                case 1062: return "Latvian";
                case 1063: return "Lithuanian";
                case 1071: return "Macedonian";
                case 1086: return "Malay (Malaysia)";
                case 2110: return "Malay (Brunei Darussalam)";
                case 1100: return "Malayalam";
                case 1082: return "Maltese";
                case 1153: return "Maori";
                case 1102: return "Marathi";
                case 1104: return "Mongolian";
                case 1044: return "Norwegian (Bokmal)";
                case 2068: return "Norwegian (Nynorsk)";
                case 1045: return "Polish";
                case 1046: return "Portuguese (Brazilian)";
                case 2070: return "Portuguese (Standard)";
                case 1094: return "Punjabi";
                case 1131: return "Quechua (Bolivia)";
                case 2155: return "Quechua (Ecuador)";
                case 3179: return "Quechua (Peru)";
                case 1048: return "Romanian";
                case 1049: return "Russian";
                case 9275: return "Sami (Inari)";
                case 4155: return "Sami (Lule Norway)";
                case 5179: return "Sami (Lule Sweden)";
                case 3131: return "Sami (Northern Finland)";
                case 1083: return "Sami (Northern Norway)";
                case 2107: return "Sami (Northern Sweden)";
                case 8251: return "Sami (Skolt)";
                case 6203: return "Sami (Southern Norway)";
                case 7227: return "Sami (Southern Sweden)";
                case 1103: return "Sanskrit";
                case 2074: return "Serbian (Latin)";
                case 6170: return "Serbian (Latin Bosnia Herzegovina)";
                case 3098: return "Serbian (Cyrillic)";
                case 7194: return "Serbian (Cyrillic Bosnia Herzegovina)";
                case 1051: return "Slovak";
                case 1060: return "Slovenian";
                case 1034: return "Spanish (Traditional Sort)";
                case 2058: return "Spanish (Mexican)";
                case 3082: return "Spanish (Modern Sort)";
                case 4106: return "Spanish (Gautemala)";
                case 5130: return "Spanish (Costa Rica)";
                case 6154: return "Spanish (Panama)";
                case 7178: return "Spanish (Dominican Republic)";
                case 8202: return "Spanish (Venezuela)";
                case 9226: return "Spanish (Colombia)";
                case 10250: return "Spanish (Peru)";
                case 11274: return "Spanish (Argentina)";
                case 12298: return "Spanish (Ecuador)";
                case 13322: return "Spanish (Chile)";
                case 14346: return "Spanish (Uruguay)";
                case 15370: return "Spanish (Paraguay)";
                case 16394: return "Spanish (Bolivia)";
                case 17418: return "Spanish (El Salvador)";
                case 18442: return "Spanish (Honduras)";
                case 19466: return "Spanish (Nicaragua)";
                case 20490: return "Spanish (Puerto Rico)";
                case 1089: return "Swahili";
                case 1053: return "Swedish";
                case 2077: return "Swedish (Finland)";
                case 1114: return "Syriac";
                case 1097: return "Tamil";
                case 1092: return "Tatar";
                case 1098: return "Telugu";
                case 1054: return "Thai";
                case 1074: return "Tswana";
                case 1058: return "Ukrainian";
                case 1055: return "Turkish";
                case 1056: return "Urdu";
                case 1091: return "Uzbek (Latin)";
                case 2115: return "Uzbek (Cyrillic)";
                case 1066: return "Vietnamese";
                case 1106: return "Welsh";
                case 1076: return "Xhosa";
                case 1077: return "Zulu";
                default: return "Unknown";
            }
        }

        private static string GetOperatingSystemSKUName(int sku)
        {
            switch (sku)
            {
                case 0: return "Undefined";
                case 1: return "Ultimate Edition";
                case 2: return "Home Basic Edition";
                case 3: return "Home Premium Edition";
                case 4: return "Enterprise Edition";
                case 5: return "Home Basic N Edition";
                case 6: return "Business Edition";
                case 7: return "Standard Server Edition";
                case 8: return "Datacenter Server Edition";
                case 9: return "Small Business Server Edition";
                case 10: return "Enterprise Server Edition";
                case 11: return "Starter Edition";
                case 12: return "Datacenter Server Core Edition";
                case 13: return "Standard Server Core Edition";
                case 14: return "Enterprise Server Core Edition";
                case 15: return "Enterprise Server Edition for Itanium-Based Systems";
                case 16: return "Business N Edition";
                case 17: return "Web Server Edition";
                case 18: return "Cluster Server Edition";
                case 19: return "Home Server Edition";
                case 20: return "Storage Express Server Edition";
                case 21: return "Storage Standard Server Edition";
                case 22: return "Storage Workgroup Server Edition";
                case 23: return "Storage Enterprise Server Edition";
                case 24: return "Server For Small Business Edition";
                case 25: return "Small Business Server Premium Edition";
                default: return "Unknown";
            }
        }

        private static string GetOSTypeName(int osType)
        {
            switch (osType)
            {
                case 0: return "Unknown";
                case 1: return "Other";
                case 2: return "MACROS";
                case 3: return "ATTUNIX";
                case 4: return "DGUX";
                case 5: return "DECNT";
                case 6: return "Digital UNIX";
                case 7: return "OpenVMS";
                case 8: return "HPUX";
                case 9: return "AIX";
                case 10: return "MVS";
                case 11: return "OS400";
                case 12: return "OS/2";
                case 13: return "JavaVM";
                case 14: return "MSDOS";
                case 15: return "WIN3x";
                case 16: return "WIN95";
                case 17: return "WIN98";
                case 18: return "WINNT";
                case 19: return "WINCE";
                case 20: return "NCR3000";
                case 21: return "NetWare";
                case 22: return "OSF";
                case 23: return "DC/OS";
                case 24: return "Reliant UNIX";
                case 25: return "SCO UnixWare";
                case 26: return "SCO OpenServer";
                case 27: return "Sequent";
                case 28: return "IRIX";
                case 29: return "Solaris";
                case 30: return "SunOS";
                case 31: return "U6000";
                case 32: return "ASERIES";
                case 33: return "TandemNSK";
                case 34: return "TandemNT";
                case 35: return "BS2000";
                case 36: return "LINUX";
                case 37: return "Lynx";
                case 38: return "XENIX";
                case 39: return "VM/ESA";
                case 40: return "Interactive UNIX";
                case 41: return "BSDUNIX";
                case 42: return "FreeBSD";
                case 43: return "NetBSD";
                case 44: return "GNU Hurd";
                case 45: return "OS9";
                case 46: return "MACH Kernel";
                case 47: return "Inferno";
                case 48: return "QNX";
                case 49: return "EPOC";
                case 50: return "IxWorks";
                case 51: return "VxWorks";
                case 52: return "MiNT";
                case 53: return "BeOS";
                case 54: return "HP MPE";
                case 55: return "NextStep";
                case 56: return "PalmPilot";
                case 57: return "Rhapsody";
                default: return "Unknown";
            }
        }

        private static string GetProductTypeName(int productType)
        {
            switch (productType)
            {
                case 1: return "Work Station";
                case 2: return "Domain Controller";
                case 3: return "Server";
                default: return "Unknown";
            }
        }

        private static string ConvertToTimeZone(string unconverted)
        {
            int timeZone = int.Parse(unconverted);
            int copy = timeZone;
            int i = 0;
            while (timeZone >= 60)
            {
                i++;
                timeZone -= 60;
            }
            string strTimeZone = copy < 0 ? "-" : "+";
            strTimeZone += string.Format("{0}:{1}",
                                         i.ToString(CultureInfo.InvariantCulture),
                                         timeZone.ToString(CultureInfo.InvariantCulture));
            return strTimeZone;
        }

        private static string ConvertToDateTime(string unconvertedTime)
        {
            int year = int.Parse(unconvertedTime.Substring(0, 4));
            int month = int.Parse(unconvertedTime.Substring(4, 2));
            int date = int.Parse(unconvertedTime.Substring(6, 2));
            int hours = int.Parse(unconvertedTime.Substring(8, 2));
            int minutes = int.Parse(unconvertedTime.Substring(10, 2));
            int seconds = int.Parse(unconvertedTime.Substring(12, 2));
            string meridian = "AM";
            if (hours > 12)
            {
                hours -= 12;
                meridian = "PM";
            }
            string convertedTime = string.Format("{0}/{1}/{2} {3}:{4}:{5} {6}",
                                                 date.ToString(CultureInfo.InvariantCulture),
                                                 month.ToString(CultureInfo.InvariantCulture),
                                                 year.ToString(CultureInfo.InvariantCulture),
                                                 hours.ToString(CultureInfo.InvariantCulture),
                                                 minutes.ToString(CultureInfo.InvariantCulture),
                                                 seconds.ToString(CultureInfo.InvariantCulture),
                                                 meridian);
            return convertedTime;
        }
    }
}
